package cn.smxy.ln.controller;

import cn.smxy.ln.common.dto.LoginDto;
import cn.smxy.ln.common.lang.Result;
import cn.smxy.ln.pojo.User;
import cn.smxy.ln.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author ln
 * @date 2022年05月23日 18:24
 */
@RestController
@RequestMapping("/user/consumer")
public class UserConsumerController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Result login(@Validated @RequestBody LoginDto dto) {
        return userService.login(dto);
    }

    @PostMapping("/save")
    public Object save(@Validated @RequestBody User user) {
        return userService.save(user);
    }

    @PostMapping("/logout")
    public Result logout() {
        return userService.logout();
    }

    @GetMapping("/list")
    public Result queryAll() {
        return Result.succ(userService.queryAll());
    }

}
